﻿#region File Header
/***********************************************************************
 * Copyright © 2013 Beals Software
 * All Rights Reserved
************************************************************************
Author: Donald Beals
Date: February 4th, 2013
Description: TODO: Write a description of this file here.
****************************** Change Log ******************************
02.04.13 - Created initial file. (dbeals)
***********************************************************************/
#endregion

#region Using Statements
using System.Collections.ObjectModel;
#endregion

namespace GameJolt.Requests
{
	/// <summary>
	/// 
	/// </summary>
	internal sealed class RequestParameterCollection : KeyedCollection<string, RequestParameter>
	{
		#region Parameters
		public new object this[string parameterName]
		{
			get
			{
				var output = base[parameterName];
				if(output == null)
					return null;
				return output.Value;
			}
			set
			{
				RequestParameter parameter = null;
				if(!this.Contains(parameterName))
				{
					parameter = new RequestParameter(parameterName, value);
					this.Add(parameter);
				}
				else
				{
					parameter = base[parameterName];
					parameter.Value = value;
				}
			}
		}
		#endregion

		#region Methods
		protected override string GetKeyForItem(RequestParameter item)
		{
			return item.Name;
		}

		public void Add(string name, object value)
		{
			this.Add(new RequestParameter(name, value));
		}
		#endregion
	}
}
